//安全帽模块
const { ethers, upgrades } = require('hardhat')

async function main() {
  const TransparentV1 = await ethers.getContractFactory('TransparentV1')
  console.log('Deploying TransparentV1...')
  // 部署合约, 并调用初始化方法
  const myTransparentV1 = await upgrades.deployProxy(
    TransparentV1,
    [10],
    {
      initializer: 'initialize',
    },
  )
  await myTransparentV1.waitForDeployment()

  console.log('myTransparentV1: ' + JSON.stringify(myTransparentV1))
  // 代理合约地址
  const proxyAddress = myTransparentV1.target

  // 实现合约地址
  const implementationAddress = await upgrades.erc1967.getImplementationAddress(
    proxyAddress,
  )
  // proxyAdmin 合约地址
  const adminAddress = await upgrades.erc1967.getAdminAddress(proxyAddress)

  console.log(`proxyAddress: ${proxyAddress}`)
  console.log(`implementationAddress: ${implementationAddress}`)
  console.log(`adminAddress: ${adminAddress}`)
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
